import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView
  },
  {
    path: '/about',
    name: 'about',
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  },
  {
    path: '/reg',
    name: 'reg',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/home/Reg.vue')

  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/home/Login.vue'),
    redirect:'/login/loginByUsername',
    children:[{
      path: "loginByUsername",
      component:()=>import('../views/home/login/LoginByUsername.vue')
      },
      {
        path: "loginByPhone",
        component:()=>import('../views/home/login/LoginByPhone.vue')
      },
    ]
  },
  {
    path:'/detail',
    component:()=>import('../views/video/VideoDetails.vue')
  },
  {
    path:'/upload',
    component:()=>import('../views/upload/Upload.vue')
  },
  {
    path:'/release',
    component:()=>import('../views/upload/Release.vue')
  },
  {
    path:'/categoryVideo',
    component:()=>import('../views/video/CategoryVideo.vue')
  },
  {
    path:'/paySuccess',
    component:()=>import('../views/PaySuccess.vue')
  },
  {
    path:'/collect',
    component:()=>import('../views/CollectView.vue'),
    redirect: '/collect/favlist',
    children: [
      {
        path: 'favlist',
        component:()=>import('../views/collect/FavlistView.vue')
      },
      {
        path: 'video',
        component:()=>import('../views/collect/VideoView.vue')
      },
    ]
  },
  {
    path:'/personal',
    component:()=>import('../views/PersonalView.vue'),
    redirect: '/personal/index',
    children: [
      {
        path: 'index',
        component:()=>import('../views/personal/PersonalIndexView.vue'),
      },
      {
        path: 'video',
        component:()=>import('../views/personal/PersonalVideoView.vue'),
      },
      {
        path: 'post',
        component:()=>import('../views/personal/PersonalPostView.vue'),
      },
    ]
  },
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
